# Table H1

#####
rm(list=ls(all=TRUE))

library(MASS)
library(stargazer)

#### Dataset Original ####
setwd("/Users/sebastian/Dropbox/The politics of interruptions - JOP RR/Replication Files/Data Rep")
load("data_empirics_count_rep.Rdata")
load("data_empirics_length_rep.Rdata")
load("data_empirics_rep.Rdata")

data_empirics_interruptions <- data_empirics[data_empirics$interruption_final_dummy==1,]  
data_empirics_count$female_dum <- factor(data_empirics_count$female_dum, labels = c("Men", "Women"))
data_empirics_interruptions$female_dum <- factor(data_empirics_interruptions$female_dum, labels = c("Men", "Women"))

data_empirics_length$tot_num_speeches_session_10 <- (data_empirics_length$tot_num_speeches_session)/10

## Access ##
model_access_1 <- glm.nb(tot_speeches_leg_cohort ~ female_dum + ideology_ext + 
                           committee_chair + seniority + type_member +
                           party_match_pres + 
                           negative_lang_mean + mujeres_mean +
                           factor(cohort) + committee_chair*female_dum , 
                         data = data_empirics_count)

model_access_2 <- glm.nb(tot_speeches_leg_cohort ~ female_dum + ideology_ext + 
                           committee_chair + seniority + type_member +
                           party_match_pres + 
                           negative_lang_mean + mujeres_mean +
                           factor(cohort) + seniority*female_dum , 
                         data = data_empirics_count)

## Floor time ##

model_length_1 <- glm.nb(length_speech_combined_session ~ female_dum + ideology_ext + 
                           committee_chair + seniority + type_member +
                           party_match_pres + 
                           election_year  +
                           negative_lang_w + mujeres_dummy +
                           tot_num_speeches_session_10 + mean_length_leg +
                           factor(cohort) + committee_chair*female_dum 
                         , 
                         data = data_empirics_length)

model_length_2 <- glm.nb(length_speech_combined_session ~ female_dum + ideology_ext + 
                           committee_chair + seniority +type_member +
                           party_match_pres + 
                           election_year  +
                           negative_lang_w + mujeres_dummy +
                           tot_num_speeches_session_10 + mean_length_leg +
                           factor(cohort) +seniority*female_dum
                         , 
                         data = data_empirics_length)

### Floor Time Before Interruption 

model_before_int <- glm.nb(length_speech_nocont ~ female_dum + ideology_ext + 
                             committee_chair + seniority + type_member +
                             party_match_pres + 
                             election_year +
                             tot_num_speeches_session_10 + mean_length_leg +
                             negative_lang_w + mujeres_dummy +
                             factor(cohort) + committee_chair*female_dum 
                           , 
                           data = data_empirics_interruptions)

model_before_int_2 <- glm.nb(length_speech_nocont ~ female_dum + ideology_ext + 
                               committee_chair + seniority + type_member +
                               party_match_pres + 
                               election_year +
                               tot_num_speeches_session_10 + mean_length_leg +
                               negative_lang_w + mujeres_dummy +
                               factor(cohort) + seniority*female_dum
                             , 
                             data = data_empirics_interruptions)

#### TABLE H1: Interactions High Reputation ####
setwd("/Users/sebastian/Dropbox/The politics of interruptions - JOP RR/Replication Files/Table")

stargazer(model_access_1, model_access_2, model_length_1,model_length_2,
          model_before_int, model_before_int_2, 
          type = "html", style = "ajps", out = "tableH1.html",
          covariate.labels = c("Woman","Ideological Extremism","Committee Chair",
                               "Seniority","National MC","Same Party as Leg. Pres.",
                               "Negative Language (Mean)", "Topic: Women (Mean)",
                               "Election Year",
                               "Negative Language (Speech)", "Topic: Women",
                               "Speeches during Debate",
                               "Mean Length of MC Speech",
                               "Woman x Committee Chair",
                               "Woman x Seniority"),
          omit = "factor",
          no.space=TRUE,
          dep.var.labels=c("Number of Speeches","Length of Speech"),
          digits=3,
          df = FALSE,
          keep.stat = c("theta", "n"))
